from Inode import INode

class HardDisk(object):
    
    
    def __init__(self):
        self.fileSystem = "" 
        self.arrayOfDataBlocks = {} 
        self.arrayOfINodes = {}
        self.startUP()
                
        
    
    def setFS(self, aFS):
        self.fileSystem = aFS  
    
    def setDataBLocks (self, aDataBlockArray):
        self.arrayOfDataBlocks = aDataBlockArray
    
    def readDataBlock(self,aBlock):
        return self.arrayOfDataBlocks[aBlock]

    def writeDataBlock(self,aBlock,dataString):
        self.arrayOfDataBlocks[aBlock]= dataString 
        
   
    def setINodes (self, anINodeArray):
        self.arrayOfINodes = anINodeArray
        
    def getInode(self,anId):
        return self.arrayOfINodes[anId]
        
    
    
    def getDataBlockKeys(self): 
        bk = self.arrayOfDataBlocks.keys() 
        listOfBlockKeys = [] 
        listOfBlockKeys.extend(bk.__iter__())
        return listOfBlockKeys 
    
   
    def getInodeKeys(self):
        ik = self.arrayOfINodes.keys()
        listOfInodeKeys = []
        listOfInodeKeys.extend(ik.__iter__())
        return listOfInodeKeys       
            
    def startUP(self):
        x = 0
        for i in range(1024):
            self.arrayOfDataBlocks[i] = ""
            if (i % 4 == 0):
                x = x+1
        for i in range (x):
            self.arrayOfINodes[i] = INode(i)